from fastapi import FastAPI, Request
from fastapi.templating import Jinja2Templates
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
import uvicorn

app = FastAPI()
templates = Jinja2Templates("../templates")
app.mount("/static", StaticFiles(directory="../static"), name="static")

@app.get("/", response_class=HTMLResponse)
async def index(requrest: Request):
    return templates.TemplateResponse("index.html", {"request": requrest})

@app.post("/", response_class=HTMLResponse)
async def info(requrest: Request):
    data = await requrest.json()
    message = data.get('message', '')
    response = "ChatBot"

    return templates.TemplateResponse("index.html", {"request": response})


if __name__ == '__main__':
    uvicorn.run('app:app', host="127.0.0.1", port=8001, reload=True)
